
pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let table = String::from("0123456789abcdef");

    // num_str = "10(2)"
    let  num = num_str.chars().take_while(|&c| c != '(').collect::<String>();
    let from_base = num_str.chars().skip_while(|&c| c != '(').skip(1).take_while(|&c| c != ')').collect::<String>().parse::<u32>().unwrap();

    let mut result = 0;
    for c in num.chars() {
        result = result * from_base + table.find(c).unwrap() as u32;
    }
    // convert to to_base
    let mut res = String::new();
    while result > 0 {
        res.push(table.chars().nth((result % to_base) as usize).unwrap());
        result /= to_base;
    }
    return  res.chars().rev().collect::<String>();
}
